<template>
	<view class="jyq_add">

		<view class="cu-form-group ">
			<textarea maxlength="-1" v-model="form.content" @input="contentInput" placeholder="请输入京友圈加微信好友的京口令"></textarea>
		</view>
		<view class="p30 fs28 text-gray pb0">
			<view class="">温馨提示</view>
			<view class="">本工具为诚信互助工具，请大家如实发布信息，不要发布到京友圈互助无关的信息。</view>
			<view class="">本工具使用过程中有任何建议或问题，可向开发者反馈，开发者微信号：<text class="text-blue" @click="copyWeixin">{{weixin}}</text></view>
		</view>
		<view class="p30">
			<button class="cu-btn block bg-red margin-tb-sm lg" type="" @click="submit">立即发布</button>
		</view>


		<version></version>
	</view>
</template>

<script>
	import {
		setClipboardData,
		getClipboardData
	} from 'uni-clipboard';
	export default {
		data() {
			return {
				tokenKey: "token",
				form: {
					content: ""
				},
				weixin: "cxy1024p"
			}
		},
		onLoad() {
			let token = this.$utils.getStorage(this.tokenKey);
			if (!token) {
				uni.redirectTo({
					url: "../user/add"
				});
			}
			this.form.token = token;
		},
		methods: {
			contentInput() {

			},
			async copyWeixin() {
				console.log("this", this);

				let [fail, success] = await this.$to(setClipboardData(this.weixin));
				// [err,response]=await  this.$to(this.$request("",{}));

				uni.showToast({
					title: "微信号复制成功",
					icon: "none"
				});
			},
			async submit() {
				let url = "/jingyouquan/add";
				let params = this.form;
				if (!params.content) {
					this.$utils.error("请填写京口令");
					return;
				}
				let [err, response] = await this.$to(this.$request(url, params));
				console.log("res:", err, response);
				if (err) {
					this.$utils.error(err.msg);
					return
				};
				uni.reLaunch({
					url: "./jinyouquan"
				});


			}
		}
	}
</script>

<style>
	.jyq_add {}
</style>
